/*************************************************************************
> File Name: main.c
> Author: hzy
> Created Time: 2023-07-20 17:23:42
> Description: 1、计算字符串长度 2、字符串拷贝 3、字符串比较 4、字符串拼接
************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "my_str.h"

int main(int argc, char const *argv[])
{
    char *src = "AAAAA";
    char *src1 = "BBBBB";
    char dest[20] = {"AAAAA"};
    char buf[20] = {0};

    printf("计算字符串长度:\n");

    printf("strlen:%ld\n",strlen(src));
    printf("my_strlen:%ld\n",my_strlen(src));

    printf("--------------------\n");
    printf("字符串拷贝:\n");

    printf("strcpy: %s\n", strcpy(dest, src));
    printf("my_strcpy: %s\n", my_strcpy(dest, src1));

    printf("--------------------\n");
    printf("字符串拷贝(n):\n");

    printf("strncpy:%s\n", strncpy(dest, src, 2));
    printf("my_strncpy:%s\n", my_strncpy(dest, src, 3));

    printf("--------------------\n");
    printf("字符串比较:\n");

    printf("strcmp:%d\n",strcmp("zzz","BBB"));
    printf("strcmp:%d\n",strcmp("AAA","aaa"));
    printf("strcmp:%d\n",strcmp("123","123"));
    printf("my_strcmp:%d\n",my_strcmp("zzz","BBB"));
    printf("my_strcmp:%d\n",my_strcmp("AAA","aaa"));
    printf("my_strcmp:%d\n",my_strcmp("123","123"));

    printf("--------------------\n");
    printf("字符串连接:\n");

    printf("strcat:%s\n",strcat(buf,"bbb"));
    printf("my_strcat:%s\n",my_strcat(buf,"777"));

    printf("--------------------\n");
    printf("字符串连接(n):\n");

    printf("strncat:%s\n",strncat(buf,"666",2));
    printf("my_strncat:%s\n",my_strncat(buf,"111",1));    

    return 0;
}
